Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Profile changes to unblock routing #1029

Merged

Conversation

Abby-Wheelis
Copy link
Member

@Abby-Wheelis Abby-Wheelis commented Sep 11, 2023

We are almost to the point of being able to implement React routing, but first the parts of ProfileSettings that rely on settingsScope (angular) must be converted

this includes: ControlCollectionHelper, ControlSyncHelper , showLog, and showSensed

for react routing, we need to convert this page and the sync settings page

maintain access for now by routing to a React page with angular routing

using AlertBars for the error messages

first draft: scrolling the FlashList is broken and the data doesn't load unless you manually tap refresh
@Abby-Wheelis Abby-Wheelis changed the base branch from master to label_dashboard_profile_sept_2023 September 11, 2023 22:55
Abby Wheelis added 10 commits September 12, 2023 08:45
instead of making dialogStyle a parameter, export and import the stylesheet where it is used, to maintain consistency and limit parameters

Needed something similar to some of the dialogs in ProfileSettings for the SyncLogs -- so create a component `ActionMenu` to show the list of options, replacing the two hard-coded modals (carbon and force state) with an instance of ActionMenu
so each has it's own title, add a title parameter
the other page that needs conversion is the one that shows sensed data, so convert it as well

Resolved scroll issue by getting out of Angular -- using a full screen modal helps us accomplish this
we no longer rely on any of the angular code that controlled the log pages, so we can remove the files and the places they were imported
previously, was not loading more when you hit the end of the list, now the list loads more when you reach the end
load the log pages when their visibility changes, this seems cleaner than tying it to the config, since this is unrelated to the config
I was getting a mysterious "unrecognized selector" error and came to the conclusion that it was because loadStats.currentStart was null on first load, by setting a fallback, the error is resolved
these had been commented out, and by searching the codebase I came to the conclusion that they were for communicating with angular/ionic, which we no longer use

unlike other broadcasts, this is not received by other parts of our code, to trigger some action, so we don't need it
@Abby-Wheelis
Copy link
Member Author

Update to this PR -- the log and sensed pages have been converted, and are shown below.

^I just noticed the styling on these doesn't match, so I'll fix that now

There are lots of parts that are not internationalized (title of the page, error messages), @shankari do we want to start internationalizing in dev zone while we're here, or leave it in English?

I was using react-native Text when I wanted react-native-paper Text
@shankari
Copy link
Contributor

@Abby-Wheelis I think that it depends on how much effort it would be. At a high level, any OpenPATH developer is going to have to know English since all our developer documentation is in English. However, the developer zone is not only for developers, we sometimes ask participants to use it for debugging (e.g. are you in the "waiting for trip start" or the "start" state?)

So I guess my argument is that it would be good to translate if it is not too much effort. But if it is going to double the number of strings or something, we have higher priorities.

@shankari
Copy link
Contributor

^I just noticed the styling on these doesn't match, so I'll fix that now

Also, the messages are different - the one on the left shows the actual logs, the one on the right is apparently only showing state transitions??!

@Abby-Wheelis
Copy link
Member Author

So I guess my argument is that it would be good to translate if it is not too much effort. But if it is going to double the number of strings or something, we have higher priorities.

I'd say it's ~10 or fewer strings, so worth it! We've updated a bunch recently so I also need to check in with the Lao team again soon (using google translate, and can't double check like I can with Spanish).

@Abby-Wheelis
Copy link
Member Author

Also, the messages are different - the one on the left shows the actual logs, the one on the right is apparently only showing state transitions??!

The messages being different is ok, I think, since it's two different pages, which is also what we have in production now. Left page is for "check log" and right is for "check sensed". State transitions is one of three options for sensed data, Locations and Motion Types being the others, which you can change with the hamburger menu. -- Locations and Motion Types are blank lists when I check them here, and on my phone that's on production, so I need to keep looking into if this is what's expected.

@shankari
Copy link
Contributor

Locations and Motion Types are blank lists when I check them here, and on my phone that's on production, so I need to keep looking into if this is what's expected.

I think that bitrotted sometime in the distant past. They were supposed to show the list of locations and the list of motion activity objects (read from the usercache) to help debugging. I am fine with removing those - I don't remember the last time that I used them.

Abby Wheelis added 4 commits September 13, 2023 09:14
Adding translations for the user-visible strings to ensure users can access the dev zone, the logs will be in English, but with headers and error messages in selected language participating in debugging will be easier
we don't need these show sensed or show logs anymore!
these two options are not supported, so we should not present them to the user -- removing them leaves us with one option, so no need for an options menu

This reduces the complexity of the sensed data page significantly

note about removing options: e-mission#1029 (comment)
@Abby-Wheelis
Copy link
Member Author

I've added the i18n (only ended up being 4 strings) and removed the bit-rotted options on the sensed page. Translations for our other two languages here: Dev zone keys

Abby Wheelis added 4 commits September 14, 2023 09:09
create a React version of ControlCollectionHelper and ControlSync Helper. These hold the logic for interfacing with the plugins, as well as UI elements for editing menus and various alerts / messages

The place this is being stored has also changed, we no longer need to import from the other repos

These helpers will eliminate the last parts of React routing, and allow us to no longer rely on the broadcast of "control update complete" to ensure the UI stays up to date
medium accuracy switch was broken, now can be toggled smoothly
no longer needed, as refreshCollect settings is called after toggling accuracy, toggling tracking, and when the settings editor is closed
no longer rely on settingsScope to catch recomputeAppStatus, because we check on resume, this is not needed
@Abby-Wheelis
Copy link
Member Author

This fix is far from polished, but I think I've unblocked React routing from the profile at this point. ControlCollectionHelper, ControlSyncHelper , showLog, and showSensed have all been rewritten into React components. I was also able to remove all references to settingScope because the last reliance on that variable was catching "recomputeAppStatus" broadcasts, which are redundant anyways after the introduction of the custom hook for "on resume".

The migration that I was hoping to do of some of the logical code from ProfileSettings into the new helpers is held back by the error message AlertBars. If I move the functions that show the bars into the helpers, I would have to pass the visibility states as parameters and leave the bars themselves in ProfileSettings because of the way React does not allow exporting functions from within a component. This splitting feels clunky, but might be what React wants. I think ideally there would be some way to throw the "alerts" from within the function like we were in angular/ionic but I haven't figured out how that could work yet. There's a few functions that also make use of the angular service "Logger" which isn't available outside of components (judging by the error messages) so that is another blocker to the "logical migration / cleanup" that I was hoping to start here.

@Abby-Wheelis
Copy link
Member Author

Abby-Wheelis commented Sep 14, 2023

We just talked about some ways to work through this "alert" issue:

  • when we're fully in React Native, we can use React Native's alert
  • could use an external library to accomplish something like React Native's alert in the current react native web
  • could use the global "window.alert" (as a temporary solution)
  • could potentially render the "force sync" button, etc, as a separate component, export it separately, and embed it directly in profile settings

Abby Wheelis added 5 commits September 14, 2023 14:05
the debouncing patch for toggleLowAccuracy is no longer needed!
since these arguments are optional, and we render based on their existence, set the default to undefined
no longer need to debounce, so no need to keep code around
to start decluttering `ProfileSettings` move the component to the ControlSyncHelper then import it into `Profile Settings` by exporting a component, we can wrap the popups and their states into one place
this was one way I attempted to control the ControlSettings, but moved to set/get from a central location (plugin) for one-off changes (toggles) and using the local config, and saving once, when editing with the settings editor modal
@Abby-Wheelis
Copy link
Member Author

could potentially render the "force sync" button, etc, as a separate component, export it separately, and embed it directly in profile settings

This is what I've done, for now, with force sync. Now I'm realizing "endForceSync" (ends a trip then forces a sync) relies on that function too. I could easily remedy this if I put the rows next to each other. Currently, forceSync is outside of devzone and endForceSync is inside. Could they both be inside? How often do users usually force a sync?

Abby Wheelis added 3 commits September 15, 2023 16:19
moving endForceSync and forceTransition into their respective helpers
@shankari
Copy link
Contributor

Now I'm realizing "endForceSync" (ends a trip then forces a sync) relies on that function too. I could easily remedy this if I put the rows next to each other. Currently, forceSync is outside of devzone and endForceSync is inside. Could they both be inside? How often do users usually force a sync?

Can you clarify why do they need to be next to each other given that they are separate components?

Having said that, I am OK with rmoving "Force Sync" into the developer zone. The only reason it is outside right now is because one of the early studies, which only ran for a week, wanted to make sure that participants had uploaded all their data, so wanted to "force sync" at the end of the study.

We haven't had thta requirement for a while now, probably because we are so focused on longitudinal data collection. So I think it is fine to change it now.

@Abby-Wheelis
Copy link
Member Author

Can you clarify why do they need to be next to each other given that they are separate components?

While they are separate components, endForceSync calls forceSync and therefore also relies on the same success/error message components as forceSync. If it was just a message, I could use "window.alert" and they wouldn't rely on the same component. But one of the things that forceSync can show is a "data pending" consent dialog, that requires collecting and handling user input:

then(function(syncPending) { Logger.log("sync launched = "+syncPending); if (syncPending) { Logger.log("data is pending, showing confirm dialog"); setDataPendingVis(true); //consent handling in modal

By calling forceSync, endForceSync needs to share all of the same "hidden" UI components with forceSync

Abby Wheelis added 3 commits September 18, 2023 10:01
for consistency and readability, re-writing the forceSync to rely on await rather than chained .then statements
for readability, switch from chained .then statements to using await calls
@Abby-Wheelis Abby-Wheelis marked this pull request as ready for review September 18, 2023 16:42
@shankari shankari changed the base branch from label_dashboard_profile_sept_2023 to onboarding_routing_sept_2023 September 25, 2023 04:46
Copy link
Contributor

@shankari shankari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with merging this as-is, although I would like you to address my comments in a separate cleanup PR

www/js/control/AppStatusModal.tsx Show resolved Hide resolved
www/js/control/ControlCollectionHelper.tsx Show resolved Hide resolved
www/js/control/ControlSyncHelper.tsx Show resolved Hide resolved
www/js/control/ControlSyncHelper.tsx Show resolved Hide resolved
www/js/control/LogPage.tsx Show resolved Hide resolved
www/js/control/ProfileSettings.jsx Show resolved Hide resolved
const [showingSensed, setShowingSensed] = useState(false);
const [showingLog, setShowingLog] = useState(false);
const [editSync, setEditSync] = useState(false);
const [editCollection, setEditCollection] = useState(false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused about the interaction between editCollection and editCollectionConfig.
I see that there is an editCollectionConfig which sets editCollection to true, which presumably opens the popup for the edit. But then what does editCollection do, and how does it interact with the refreshCollectionSettings in the useEffect below, and in the control.update.complete event broadcast from the helper

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The control.update.complete event broadcast cannot be relied on anymore, as it was intertwined with Angular routing.

editCollectionConfig is what is called when the user clicks the pencil, setting editCollection to true and showing the editor menu. When the menu is closed, we want refreshCollectionSettings to be called so the useEffect calls refreshCollectionSettings if editCollection changes (it will become false when the editor is closed). This way, the UI for the settings is updates without having to rely on the broadcast events from angular.

Does that help explain things?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Address code reviews with "future"
Development

Successfully merging this pull request may close these issues.

2 participants